/****************************************************************************

Force Engine v0.5

Creado: 25/04/09
Clase: BSPNode.cpp
Hecho by: Pedro Mancheno

****************************************************************************/

//---------------------------------------------------------------------------
#include "BSPNode.h"
//---------------------------------------------------------------------------
BSPNode::BSPNode(Graphics &rkGraphics)
:
Node(rkGraphics)
{
	m_iType = TYPE_BSP_NODE;
}
//---------------------------------------------------------------------------
BSPNode::~BSPNode()
{

}
//---------------------------------------------------------------------------
bool BSPNode::Initialize(std::string szName, INode * pkParentNode)
{
	return true;
}
//---------------------------------------------------------------------------
/*const BVH * BSPNode::Update()
{
}*/
//---------------------------------------------------------------------------
bool BSPNode::AddChildNode(INode * pkChildNode)
{
	return true;
}
//---------------------------------------------------------------------------
void BSPNode::RemoveChildNode(INode * pkChildNode)
{
}
//---------------------------------------------------------------------------
void BSPNode::Draw()
{
}
//---------------------------------------------------------------------------
int BSPNode::WhichSideIsOn(D3DXVECTOR3 rkEyePos, Plane rkPlane)
{
	float fpDistance = 0;
	float fpSideValue = 0;

	fpSideValue = DotProduct(rkPlane.GetNormal(),rkEyePos);
	fpDistance = PointDistance(rkPlane.GetPoint(), rkEyePos);

	if(fpSideValue == fpDistance)
	{
		return COINCIDING;
	}
	else if(fpSideValue < fpDistance)
	{
		return BEHIND;
	}
	else
	{
		return INFRONT;
	}
}
//---------------------------------------------------------------------------
void BSPNode::SetPlane(Plane rkPlane)
{
	m_pkHyperPlane = &rkPlane;
}
//---------------------------------------------------------------------------
void BSPNode::SetLeftNode(INode * pkNode)
{
	m_pkLeftNode = pkNode;
}
//---------------------------------------------------------------------------
void BSPNode::SetRightNode(INode * pkNode)
{
	m_pkRightNode = pkNode;
}
//---------------------------------------------------------------------------
Plane * BSPNode::GetPlane()
{
	return m_pkHyperPlane;
}
//---------------------------------------------------------------------------
INode * BSPNode::GetLeftNode()
{
	return m_pkLeftNode;
}
//---------------------------------------------------------------------------
INode * BSPNode::GetRightNode()
{
	return m_pkRightNode;
}
//---------------------------------------------------------------------------